<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/template/template_layout_lrt.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span,
	.ui-button.ui-state-default span {
	font-weight: normal
}
</style>
	</ui:define>
	<ui:define name="top-box-tools">
		<h:form id="btnForm">
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
				<p:commandButton value="是" type="button"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="否" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>
			<p:growl id="msgs" showDetail="true" />
			<p:toolbar id="btnBar" rendered="#{s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_xjpgmx') or 
				s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_xzpgx') or s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_bjdjqz')
				or s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_bj') or s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_bj')
				or s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_sc')}">
				<f:facet name="left">
					<p:commandButton icon="ui-icon-document" value="新建评估模型"
						style="font-weight:normal" update="cgform"
						oncomplete="PF('createRiskEvaluateModelDialog').show()"
						rendered="#{s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_xjpgmx')}"
						actionListener="#{riskEvaluateModelController.preCreate('model')}" />
					<p:commandButton icon="ui-icon-document" value="编辑评估模型"
						rendered="#{riskEvaluateModelController.selectedNode != null and 'model'.equals(riskEvaluateModelController.selectedNode.type) 
							and s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_xjpgmx')}"
						update="cgform"
						oncomplete="PF('createRiskEvaluateModelDialog').show()"
						actionListener="#{riskEvaluateModelController.preUpdate('model')}" />
					
					<p:commandButton icon="ui-icon-trash"
						update=":leftForm:tree  :rightForm:plist btnBar"
						rendered="#{riskEvaluateModelController.selectedNode != null and 'model'.equals(riskEvaluateModelController.selectedNode.type) and s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_sc')}"
						actionListener="#{riskEvaluateModelController.delete()}"
						value="删除评估模型">
						<p:confirm header="提示"
							message="将删除该记录下所有记录，删除后，该记录将无法恢复，确定删除选中的记录吗?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton icon="ui-icon-document"
						rendered="#{riskEvaluateModelController.selectedNode != null and 'rfmodel'.equals(riskEvaluateModelController.selectedNode.type) and s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_xzpgx')}"
						update="crform"
						actionListener="#{riskEvaluateModelController.preCreate('mitem')}"
						value="新增评估项" oncomplete="PF('createModelItemDialog').show()" />
					<p:commandButton icon="ui-icon-document"
						disabled="#{riskEvaluateModelController.rfModelItem== null}"
						rendered="#{s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_bjpgx')}"
						value="编辑评估项" update="crform"
						oncomplete="PF('createModelItemDialog').show()"
						actionListener="#{riskEvaluateModelController.preUpdate('mitem')}" />
					<p:commandButton icon="ui-icon-document"
						disabled="#{riskEvaluateModelController.rfModelItem== null}"
						update="clform btnBar"
						rendered="#{s:hasPermission(session,'xtsz_fxpgcssz_fxpgmx_bjdjqz')}"
						actionListener="#{riskEvaluateModelController.preCreate('level')}"
						value="编辑等级权重" oncomplete="PF('createRiskLevelDialog').show()" />
				</f:facet>
			</p:toolbar>
		</h:form>
	</ui:define>
	<ui:define name="left-box-title">
		风险评估模型树
	</ui:define>
	<ui:define name="left-box-body">
		<h:form id="leftForm">
			<p:tree value="#{riskEvaluateModelController.root}" var="node"
				dynamic="true" id="tree" widgetVar="tree" animate="true"
				selectionMode="single"
				selection="#{riskEvaluateModelController.selectedNode}"
				style="border:0">
				<p:ajax event="expand" update="tree"
					listener="#{riskEvaluateModelController.onNodeExpand}" />
				<p:ajax event="select"
					update="tree :btnForm:btnBar :rightForm:plist"
					listener="#{riskEvaluateModelController.onNodeSelect}" />
				<p:treeNode type="model" expandedIcon="ui-icon-folder-open"
					collapsedIcon="ui-icon-folder-collapsed">
					<h:outputText value="#{node}" />
				</p:treeNode>
				<p:treeNode type="rfmodel" icon="ui-icon-note">
					<h:outputText value="#{node}" />
				</p:treeNode>
				<!-- <p:treeNode type="mitem" icon="ui-icon-note">
					<h:outputText value="#{node}" />
				</p:treeNode>
				<p:treeNode type="num" icon="ui-icon-note">
					<h:outputText value="#{node}" />
				</p:treeNode> -->
			</p:tree>
		</h:form>
	</ui:define>
	<ui:define name="right-box-title">
		评估项信息列表
	</ui:define>
	<ui:define name="right-box-body">
		<div id="div1">
			<h:form id="rightForm">
				<p:dataTable var="mitem" id="plist"
					value="#{riskEvaluateModelController.mitems}" 
					selection="#{riskEvaluateModelController.rfModelItem}"
					rowKey="#{mitem.id}"
					selectionMode="single"
					sortBy="#{mitem.factorName}"
					widgetVar="plist" emptyMessage="无记录">
					<p:ajax event="rowSelect" update="btnForm:btnBar"></p:ajax>
					<p:column headerText="因素名称" groupRow="true">
						<h:outputText value="#{mitem.factorName}" />
					</p:column>					
					<p:column headerText="取值范围">
						<h:outputText value="#{mitem.factorMinValue}-#{mitem.factorMaxValue}" />
					</p:column>
					<p:column headerText="因素权重值">
						<h:outputText value="#{mitem.factorWeight}" />
					</p:column>	
					<p:column headerText="风险等级(主观)">
						<h:outputText value="#{mitem.riskLevel}" />
					</p:column>					
					<p:column headerText="因素说明">
						<h:outputText value="#{mitem.factorDesc}" />
					</p:column>
				</p:dataTable>
			</h:form>
		</div>
		<h:form id="cgform">
			<p:dialog widgetVar="createRiskEvaluateModelDialog" header="评估模型信息"
				closable="false" resizable="false" draggable="false" modal="true"
				width="350" height="180">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							update=":leftForm:tree  :btnForm:btnBar :rightForm:plist"
							oncomplete="PF('createRiskEvaluateModelDialog').hide()"
							actionListener="#{riskEvaluateModelController.create()}"/>
						<p:commandButton icon="ui-icon-cancel" value="取消" type="button"
							onclick="PF('createRiskEvaluateModelDialog').hide()" />
					</f:facet>
				</p:toolbar>
				<p:panelGrid id="modelInfopg" columns="2" cellpadding="4" style="width:100%">
					<h:outputText value="模型名称:" />
					<p:inputText value="#{riskEvaluateModelController.current.name}" />
					<h:outputText value="模型说明:" />
					<p:inputText
						value="#{riskEvaluateModelController.current.modelDesc}" />
				</p:panelGrid>
				
			</p:dialog>
		</h:form>
		<h:form id="crform">
			<p:dialog widgetVar="createModelItemDialog" header="评估信息项信息"
				closable="false" resizable="false" draggable="false" modal="true"
				width="400" height="300">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							update=":btnForm:btnBar :rightForm:plist"
							oncomplete="PF('createModelItemDialog').hide()"
							actionListener="#{riskEvaluateModelController.create()}" />
						<p:commandButton icon="ui-icon-cancel" value="取消" type="button"
							onclick="PF('createModelItemDialog').hide()"
							style="margin-left:5px" />
					</f:facet>
				</p:toolbar>
				<p:panelGrid id="modelItemInfopg" columns="2" cellpadding="4" style="width:100%">					
					<h:outputText value="因素名称:" />
					<!-- <h:selectOneMenu id="select"
						value="#{riskEvaluateModelController.current.factorName}"
						required="true" label="因素名称" style="width:70%">
						<f:selectItem itemLabel="请选择" itemValue="" />
						<f:selectItems value="#{riskEvaluateModelController.riskFactors}"
							var="riskFactor" itemLabel="#{riskFactor.name}" itemValue="#{riskFactor.name}" />
					</h:selectOneMenu> -->
					<p:inputText  value="#{riskEvaluateModelController.current.factorName}" readonly="true" />
					<h:outputText value="最小发生值:" />
					<p:inputText
						value="#{riskEvaluateModelController.current.factorMinValue}"  >
					</p:inputText>
					<h:outputText value="最大发生值:" />
					<p:inputText
						value="#{riskEvaluateModelController.current.factorMaxValue}" >
					</p:inputText>
					<h:outputText value="风险等级(主观):" />
					<p:selectOneMenu value="#{riskEvaluateModelController.current.riskLevel}" style="width:80%">
			            <f:selectItem itemLabel="请选择" itemValue="正常" />
			            <f:selectItem itemLabel="低风险" itemValue="低风险" />
			            <f:selectItem itemLabel="中风险" itemValue="中风险" />
			            <f:selectItem itemLabel="高风险" itemValue="高风险" />
        			</p:selectOneMenu>
					<!-- <p:inputText
						value="#{riskEvaluateModelController.current.riskLevel}" >
					</p:inputText> -->
					<h:outputText value="因素权重值:" />
					<p:inputText
						value="#{riskEvaluateModelController.current.factorWeight}" >
					</p:inputText>
					<h:outputText value="因素说明:" />
					<p:inputText
						value="#{riskEvaluateModelController.current.factorDesc}" />
				</p:panelGrid>
			</p:dialog>
		</h:form>
		<h:form id="clform">
			<p:dialog widgetVar="createRiskLevelDialog" header="风险等级权重信息"
				closable="false" resizable="false" draggable="false" modal="true"
				width="500" height="400">	
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton icon="ui-icon-cancel" value="关闭" type="button"
							onclick="PF('createRiskLevelDialog').hide()" />
					</f:facet>
				</p:toolbar>
				
				#{riskEvaluateModelController.showInfo}			
				<p:dataTable var="rlevel" id="rllist"
					value="#{riskEvaluateModelController.rlevels}"
					rowKey="#{rlevel.id}" widgetVar="rllist" emptyMessage="无记录"
					editable="true" editMode="cell">
					<p:ajax event="cellEdit" 
						listener="#{riskEvaluateModelController.onCellEdit}"  />
					<p:column headerText="等级名">
						<h:outputText value="#{rlevel.levelName}" />
					</p:column>
					<p:column headerText="权重值">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{rlevel.levelWeight}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{rlevel.levelWeight}" />
							</f:facet>
						</p:cellEditor>
					</p:column>
				</p:dataTable>
			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>